|
|
|
|
|
|
|
built-in database engine rules because program commands do not directly access the database. You also can cancel changes to your edited data without using transactions. In other words, your program can examine the input data before an attempt is made to enter the data into the database. The use of program commands also provides an efficient way to handle data input and searches that do not require user interaction. Examples are receiving data from lab equipment or across a modem, or looking up the price of an item in a table. Program commands enable you to perform transaction processing as well. |
|
|
|
|
|
|
|
|
Before you can use any database capabilities (beyond the Data control and bound controls) in your program, you must specify one of the Data Access Object libraries in your program's references. |
|
|
|
|
|
|
|
|
To set the program references, choose Project, References and then select one of the Microsoft DAO libraries from the References - ProjectName dialog box (see Figure 26.2). |
|
|
|
|
|
|
|
|
Figure 26.2
Adding a reference to the DAO library makes
these objects available to your program. |
|
|
|
|
|
|
|
|
|
Visual Basic can include two basic Jet DAO libraries in an application. These external libraries are the Microsoft DAO 3.51 Object Library and the Microsoft DAO 2.5/3.51 Compatibility Library. If you plan to program for 32-bit clients only and use 32-bit Jet (Access 95/97) databases, select the 3.51 library. If you need to exchange data with 16-bit systems or Access 2.0 applications, use the 2.5/3.51 compatibility library.  |
|
|
|
|
|
|
|
|
|
|
Within a program, a database is opened as part of a session with the database engine. The database engine is represented within a Visual Basic program by the DBEngine object; you define sessions by creating one or more Workspace objects within the DBEngine object. By default, once a project contains a reference to a DAO library, the DBEngine object and a single Workspace object, known as Workspaces(0) (because it is the first member of the zero-based Workspaces collection), are automatically created. These default objects are sufficient for most DAO projects. |
|
|
|
|
|